/**
 * @file A_shell.h
 * @author MooN
 * @brief 
 * @version 0.0.1
 * @date 2022-08-24
 * 
 * @copyright (c) 2022 Moon
 * 
 */

#ifndef _A_SHELL_H__
#define _A_SHELL_H__
#include <stdint.h>
#include "shell.h"

#define ASHELL_VERSION    "V0.0.4"
#define COLOR_RESET   0
#define COLOR_RED     31
#define COLOR_YELLOW  33
#define COLOR_CYAN    36

#define PREFIX_INFO   ""
#define PREFIX_WARN   "WARN"
#define PREFIX_ERROR  "ERROR"


extern Shell shell;

#define PRINT_WARN(...) \
    do { \
        shellPrint(&shell, "\033[%dm%s[%s][%d]:\033[0m ", COLOR_RED, PREFIX_WARN, __func__, __LINE__); \
        shellPrint(&shell, __VA_ARGS__); \
    } while (0)

#define PRINT_INFO(...) \
do { \
	shellPrint(&shell, "\033[%dm%s[%s][%d]:\033[0m ", COLOR_YELLOW, PREFIX_INFO, __func__, __LINE__); \
	shellPrint(&shell, __VA_ARGS__); \
} while (0)


#define Ashell_print(...)           shellPrint(&shell, __VA_ARGS__)
#define Ashell_EndLine(buff, len)   shellWriteEndLine(&shell, buff, len)    //尾行模式-数据输出接口

void AShellInit(signed short (*write)(char *, unsigned short), int (*flush)(void));
uint16_t Ashell_rx_callback(uint8_t *data, uint16_t len);

#if ASHELL_ASYNCHRONOUS == 1
void Ashell_task(void);
short Ashell_read(uint8_t *data, unsigned short len);
short Ashell_write(uint8_t *data, unsigned short len);
short Ashell_flush_read(uint8_t *data, unsigned short len);
#endif

#endif
